package string;
/** static String valueOf(数据类型 a) 转换类型 */
public class ValueOfDemo {
    public static void main(String[] args) {
        int a =123;
        String s1 = String.valueOf(a);//将int型变量a转换为String类型并赋值给s1
        System.out.println(s1);//123 --- 字符串类型

        double b = 123.456;
        String s2 = String.valueOf(b);//将doouble型变量b转换为String类型并赋值给说
        System.out.println(s2);//123.456 --- 字符串类型

        String s3 = b + "";//任何类型与字符串相连，结果都会变为字符串类型，效率低
        System.out.println(s3);//123.456 --- 字符串类型

        int c = 456;
        double d = 456.789;
        String s5 = String.valueOf(c);
        System.out.println(s5);
        String s6 = String.valueOf(b);
        System.out.println(s6);
        String s7 = c+"";
        System.out.println(s7);
    }
}
